package com.sls.game.dao.xingxitian.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.game.dao.impl.SuperDAO;
import com.sls.game.dao.xingxitian.XingParvalueDAO;
import com.sls.game.page.Pagination;
import com.sls.game.pojo.xingqitian.XingParvalueInfo;

/**
 * 
 * @description
 * @author Wangxuegang
 * @date 2012-12-22
 */
@Repository("xingParvalueDAO")
public class XingParvalueDAOImpl extends SuperDAO<XingParvalueInfo> implements
		XingParvalueDAO {

	@Override
	public void insert(XingParvalueInfo info) {
		this.getSqlSession().insert("mybatis.xml.XingParvalueMapper.insert",
				info);
	}

	@Override
	public XingParvalueInfo queryParvalueById(String id) {
		XingParvalueInfo info = this.getSqlSession().selectOne(
				"mybatis.xml.XingParvalueMapper.queryParvalueById", id);
		return info;
	}

	@Override
	public Pagination<XingParvalueInfo> queryParvalueInfo(XingParvalueInfo info) {
		Pagination<XingParvalueInfo> paginationList = null;
		Integer rowCount = queryRowCount(info);
		info.calculate();
		List<XingParvalueInfo> list = queryParvalueInfoList(info);
		paginationList = this.queryPagination(rowCount, list, info);
		return paginationList;
	}

	/**
	 * 查询记录总数
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private Integer queryRowCount(XingParvalueInfo info) {
		Integer rowCount = this.getSqlSession().selectOne(
				"mybatis.xml.XingParvalueMapper.queryRowCount", info);
		return rowCount;
	}

	/**
	 * 记录结果集list
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private List<XingParvalueInfo> queryParvalueInfoList(XingParvalueInfo info) {
		List<XingParvalueInfo> list = this
				.getSqlSession()
				.selectList(
						"mybatis.xml.XingParvalueMapper.queryXQTParvalueInfoList",
						info);
		return list;
	}

	/**
	 * 根据gametype1和parvalueName查询记录
	 * 
	 * @param info
	 * @return
	 */
	@Override
	public XingParvalueInfo queryParvalueByGametype1(XingParvalueInfo info) {
		XingParvalueInfo xingParvalueInfo = null;
		xingParvalueInfo = this
				.getSqlSession()
				.selectOne(
						"mybatis.xml.XingParvalueMapper.queryParvalueByGametype1",
						info);
		return xingParvalueInfo;
	}

	@Override
	public List<XingParvalueInfo> queryAllParvalueInfo(XingParvalueInfo isAudit) {
		List<XingParvalueInfo> list = this.getSqlSession().selectList(
				"mybatis.xml.XingParvalueMapper.queryAllParvalueInfo", isAudit);
		return list;
	}

	@Override
	public XingParvalueInfo queryParvalueInfoByGoodsId(String goodsId) {
		XingParvalueInfo info = this.getSqlSession().selectOne(
				"mybatis.xml.XingParvalueMapper.queryParvalueInfoByGoodsId",
				goodsId);
		return info;
	}

	@Override
	public void updateState(XingParvalueInfo info) {
		this.getSqlSession().update(
				"mybatis.xml.XingParvalueMapper.updateState", info);
	}

	@Override
	public String queryMaxGoodsId() {
		String maxGoodsId = this.getSqlSession().selectOne(
				"mybatis.xml.XingParvalueMapper.queryMaxGoodsId");
		return maxGoodsId;
	}

	/**
	 * 根据商品编号，查询chargetype信息
	 * 
	 * @param originalGoodsId
	 * @return
	 */
	@Override
	public List<XingParvalueInfo> queryChargeTypeByGoodsId(
			String originalGoodsId) {
		List<XingParvalueInfo> list = null;
		list = this.getSqlSession().selectList(
				"mybatis.xml.XingParvalueMapper.queryChargeTypeByGoodsId",
				originalGoodsId);
		return list;
	}

}
